import Vue from "vue";
import App from "./App";
import VueRouter from 'vue-router';
import routes from './router'
import Vuex from 'vuex'
import state from './store/state';
import axios from './axios/http';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(Vuex);
Vue.use(VueRouter);
Vue.use(ElementUI);
const router = new VueRouter({
    routes
})
const store = new Vuex.Store({...state});

axios.install(Vue);
//路由权限思路/实现思路
//1,后台返回路由结构前端渲染,
//2,前端创建权限数据,登录成功后拿到用户权限,根据route.meta元信息,删除本地权限数据,在注入vue
//3,router.beforeEach同上2 可匹配注入,可实现不是最佳实现

// router.beforeEach((to,from,next)=> {
    // 未登录跳登录/有路由元信息状态 ,有token登录
    // if (to.matched.some(res => res.meta.isLogin)) {
    //     if (!token) {
    //         next({
    //             path: '/login',
    //             query: { redirect: to.fullPath }
    //         })
    //     } else {
    //         next()
    //     }
    // } else {
    //     next()
    // }
// })



new Vue({
    router,
    store,
    axios,
    render: h => h(App),
}).$mount('#app');